package containers;

import java.util.HashMap;

import dbadapters.checkConnection;

import entities.FinancialInfo;
import entities.Loan;
import entities.Student;

/**
 * A singleton class to access the dictionary containing the students
 */
public class NewLoanContainer {

	/** Private constructor to ensure that no instance is created. */
	private NewLoanContainer() {
	}

	/** The dictionary for accessing Employees */
	private static HashMap<Integer, Student> dictionary;

	/**
	 * Return the dictionary that maps unique ids to Students
	 * 
	 * @return the dictionary that maps ids to students
	 */
	public static HashMap<Integer, Student> dictionary() {
		if (dictionary == null) {
			/* Create the initial dictionary. */
			dictionary = new HashMap<Integer, Student>(10);

			checkConnection c = new checkConnection();

			// if conncection does not exist, hardcode some examples
			if (!c.isConnectionValid()) {
				// add students to dictionary
				Student student1 = new Student(123456, "123456");
				student1.setAddress("123 Fake St");
				student1.setBirthdate("01/01/2005");
				student1.setCitizenship(true);
				student1.setEmail("123@google.com");
				student1.setFatherEducation(Student.education.DEGREE);
				student1.setInstitution("UofS");
				student1.setName("Stewie Griffin");
				student1.setSIN("465467823");
				student1.setPhoneNumber("222-2222");
				student1.setMotherEducation(Student.education.HIGH_SCHOOL);
				student1.setMaritalStatus(Student.maritalStatuses.SINGLE);

				Loan loan1 = new Loan(student1);
				loan1.setAmountRequested(5000.00);
				loan1.setIsNew(true);
				student1.setLoan(loan1);

				FinancialInfo finInfo1 = new FinancialInfo();
				finInfo1.setChildSupport(0);
				finInfo1.setHouseholdIncome(100000);
				finInfo1.setPersonalIncome(10000);
				finInfo1.setScholarship(0);
				finInfo1.setTaxableEarnings(0);
				student1.setFinances(finInfo1);

				dictionary.put(123456, student1);

				Student student3 = new Student(012345, "012345");
				student3.setAddress("456 Fake St");
				student3.setBirthdate("01/01/1972");
				student3.setCitizenship(true);
				student3.setEmail("584@google.com");
				student3.setFatherEducation(Student.education.DEGREE);
				student3.setInstitution("UofS");
				student3.setName("Lois Griffin");
				student3.setSIN("465467898");
				student3.setPhoneNumber("222-2222");
				student3.setMotherEducation(Student.education.HIGH_SCHOOL);
				student3.setMaritalStatus(Student.maritalStatuses.MARRIED);

				Loan loan3 = new Loan(student3);
				loan3.setAmountRequested(5000.00);
				loan3.setIsNew(true);
				student3.setLoan(loan3);

				FinancialInfo finInfo3 = new FinancialInfo();
				finInfo3.setChildSupport(200000);
				finInfo3.setHouseholdIncome(600000);
				finInfo3.setPersonalIncome(10000);
				finInfo3.setScholarship(1000);
				finInfo3.setTaxableEarnings(1000);
				student3.setFinances(finInfo3);

				dictionary.put(012345, student3);

			}

		}
		return dictionary;
	}

}